package Exercise;

import java.util.Scanner;

/**
 * Description：
 * Author: zhangc
 * Date：2017/8/14 20:45
 */
public class PalindromicNum {


    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int total = scanner.nextInt();
//        int[] array = new int[ total ];
//        for (int i = 0; i < total; i++) {
//            array[ i ] = scanner.nextInt();
//        }
        int[] array = {1, 1, 2};
        int total = array.length;
        System.out.println(transSeq(array, total - 1));
    }

    public static int transSeq(int[] nums, int len) {
        int left = nums[ 0 ], right = nums[ len ];
        int i = 1, j = len - 1, count = 0;
        for (; i <= j; ) {
            if (left < right) {
                left += nums[ i++ ];
                ++count;
            } else if (left > right) {
                right += nums[ j-- ];
                ++count;
            } else {
                left = nums[ i ];
                right = nums[ j ];
            }
        }
        return left == right ? count : count + 1;
    }
}
